
const data = {
	contract: '',
	AskPrice: 0,
	AskVolume: 0,
	BidPrice: 0,
	BidVolume: 0,
	LastPrice: 0,
	Time: Date.now()
}

async function main(market, base, quote) {

	const url = `https://www.bitstamp.net/api/v2/ticker/${base}${quote}/`

	try {
		const {statusCode, body} = await Request.getAsync(url, {timeout: config.timeout, json: true})
		// console.log(url, statusCode, body)

		if (statusCode == 200) {
			data[0] = Number(body.last)
			data[1] = Number(body.ask)
			data[2] = Number(body.bid)
			Cache.hmset('data', data)
		}
	} catch (error) {
		LOG([market, error.code || error.message || error])
	}

	await Promise.delay(config.timeout * 0.5)
	main(market, base, quote)
}

module.exports = main
